<!DOCTYPE html>
<html>
<head lang="en">
	<meta charset='utf-8'/>
	<title>前后端交互-登录案例</title>
</head>
<body>

<span>用户名：</span><input type="text" class="username"/><br/>
<span>密码：</span><input type="text" class="password"/><br/>
<button>用户登录</button>

<script src='js/jquery-1.12.3.min.js'></script>
<script>
	
	$('button').click(function (){
		$.ajax({
			type:'post',
			url:'04loginDemo.php',
			dataType:'json',
			data:{
				myUname:$('.username').val(),
				myUpass:$('.password').val()
			},
			success:function (res){
				console.log(res);
				if(res.infoCode == 0){
					alert('登录失败，用户名或密码错误');
				}else{
					alert('登录成功');
				}
			}
		});
	});


</script>
</body>
</html>